Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lazy-req

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-req

Require modules lazily

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

lazy-req Build Status

Require modules lazily

Install

$ npm install --save lazy-req

Usage

// pass in `require` or a custom require function
var lazyReq = require('lazy-req')(require);
var _ = lazyReq('lodash');

// where you would normally do
_.isNumber(2);

// you now instead call it as a function
_().isNumber(2);

// it's cached on consecutive calls
_().isString('unicorn');

// extract lazy variations of the props you need
var members = lazyReq('lodash')('isNumber', 'isString');

// useful when using destructuring assignment in ES2015
const { isNumber, isString } = lazyReq('lodash')('isNumber', 'isString');

// works out of the box for functions and regular properties
var stuff = lazyReq('./math-lib')('sum', 'PHI');
console.log(stuff.sum(1, 2)); // => 3
console.log(stuff.PHI); // => 1.618033

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 10 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc